import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },


  {
    path: '/sign',
    component: Layout,
    name: 'Example',
    meta: { title: '签约管理', icon: 'example' },
    children: [
      {
        path: 'pendingSign',
        name: 'PendingSign',
        component: () => import('@/views/sign/pendingSign/index'),
        meta: { title: '待处理签约', icon: 'table' }
      },
      {
        path: 'detail/:id',
        name: 'Detail',
        component: () => import('@/views/sign/detail'),
        meta: { title: '查看详情', icon: 'table' },
        hidden: true
      },
      {
        path: 'edit/:id',
        name: 'Edit',
        component: () => import('@/views/sign/edit'),
        meta: { title: '编辑', icon: 'table' },
        hidden: true
      },
      {
        path: 'logsSign',
        name: 'LogsSign',
        component: () => import('@/views/sign/logsSign/index'),
        meta: { title: '签约记录', icon: 'tree' }
      },
      {
        path: 'logsSignDetail/:id',
        name: 'LogsSignDetail',
        component: () => import('@/views/sign/logsSign/detail'),
        meta: { title: '查看记录详情', icon: 'table' },
        hidden: true
      },

    ]
  },

  {
    path: '/service',
    component: Layout,
    name: 'Example',
    meta: { title: '服务管理', icon: 'example' },
    children: [
      {
        path: 'pendingService',
        name: 'pendingService',
        component: () => import('@/views/service/pendingService/index'),
        meta: { title: '待处理服务', icon: 'form' }
      },
      {
        path: 'servicerecord',
        name: 'servicerecord',
        component: () => import('@/views/fw/servicerecord'),
        meta: { title: '服务记录', icon: 'form' }
      },
      {
        path: 'detail/:id',
        name: 'Detail',
        component: () => import('@/views/service/pendingService/detail'),
        meta: { title: '查看详情', icon: 'table' },
        hidden: true
      },
      {
        path: 'edit/:id',
        name: 'Edit',
        component: () => import('@/views/service/pendingService/edit'),
        meta: { title: '编辑', icon: 'table' },
        hidden: true
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/service/pendingService/add'),
        meta: { title: '新增服务', icon: 'table' },
        hidden: true
      },
    ]
  },

  {
    path: '/user',
    component: Layout,
    meta: { title: '居民管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/user/index'),
        meta: { title: '用户管理表', icon: 'table' }
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/user/add'),
        meta: { title: '添加用户', icon: 'table' },
        hidden: true
      },
      {
        path: 'detail/:id',
        name: 'Edit',
        component: () => import('@/views/user/detail'),
        meta: { title: '查看详情', icon: 'table' },
        hidden: true
      },
      {
        path: 'edit/:id',
        name: 'Edit',
        component: () => import('@/views/user/edit'),
        meta: { title: '编辑用户', icon: 'table' },
        hidden: true
      },

    ]
  },


  {
    path: '/information',
    component: Layout,
    meta: { title: '资料管理', icon: 'example' },
    children: [
      {
        path: '/doctor',
        component: () => import('@/views/information/doctor/doctor'),
        meta: { title: '医生管理', icon: 'example' },
      },
      {
        path: '/doctor/add',
        name: 'Add',
        component: () => import('@/views/information/doctor/add'),
        meta: { title: '添加', icon: 'form' },
        hidden: true

      },
      {
        path: '/doctor/edit/:id',
        name: 'Edit',
        component: () => import('@/views/information/doctor/add'),
        meta: { title: '编辑', icon: 'form' },
        hidden: true

      },
      {
        path: '/doctorDetail/:id',
        name: 'DoctorDetail',
        component: () => import('@/views/information/doctor/doctorDetail'),
        meta: { title: '医生详情', icon: 'form' },
        hidden:true

      },
      {
        path: 'organization',
        name: 'Organization',
        component: () => import('@/views/information/organization/organization'),
        meta: { title: '机构列表', icon: 'form' }
      },
      {
        path: 'addOrganization',
        name: 'addOrganization',
        component: () => import('@/views/information/organization/addOrganization'),
        meta: { title: '添加机构', icon: 'table' },
        hidden: true
      },
      {
        path: 'editOrganization/:id',
        name: 'editOrganization',
        component: () => import('@/views/information/organization/addOrganization'),
        meta: { title: '编辑机构', icon: 'table' },
        hidden: true
      },
      {
        path: 'item',
        name: 'Item',
        component: () => import('@/views/item/item'),
        meta: { title: '服务项目管理', icon: 'table' }
      }
      ,
      {
        path: 'package',
        name: 'Package',
        component: () => import('@/views/package/package'),
        meta: { title: '服务包管理', icon: 'table' }
      },
      {
        path: '/package/detail/:id',
        component: () => import('@/views/package/detail'),
        hidden: true
      },
      {
        path: '/package/edit/:id',
        component: () => import('@/views/package/edit'),
        hidden: true
      },
      {
        path: '/package/add',
        component: () => import('@/views/package/add'),
        hidden: true
      },
      {
        path: '/team',
        name: 'team',
        component: () => import('@/views/information/team/index'),
        meta: { title: '团队管理', icon: 'table' },
      },
      {
        path: '/team/add',
        name: 'Add',
        component: () => import('@/views/information/team/add'),
        meta: { title: '添加团队', icon: 'table' },
        hidden:true
      },
      {
        path: '/team/req',
        name: 'Req',
        component: () => import('@/views/information/team/req'),
        meta: { title: '加入团队', icon: 'table' },
        hidden:true
      },
      {
        path: '/team/detail/:id',
        name: 'Detail',
        component: () => import('@/views/information/team/detail'),
        meta: { title: '查看详情', icon: 'table' },
        hidden:true
      }
      ]
  },

  {
    path: '/system',
    component: Layout,
    redirect: '/system/list',
    name: 'System',
    meta: { title: '系统设置', icon: 'example' },
    children: [
      //文章管理
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/system/article/index'),
        meta: { title: '资讯管理表', icon: 'table' }
      },
      {
        path: 'articleAdd',
        name: 'articleAdd',
        component: () => import('@/views/system/article/add'),
        meta: { title: '添加文章', icon: 'table' },
        hidden: true
      },
      {
        path: 'articleEdit/:id',
        name: 'articleEdit',
        component: () => import('@/views/system/article/add'),
        meta: { title: '编辑文章', icon: 'table' },
        hidden: true
      },
      //药品管理
      {
        path: 'medicineList',
        name: 'medicineList',
        component: () => import('@/views/system/medicine/index'),
        meta: { title: '药品管理表', icon: 'table' }
      },
      {
        path: 'medicineAdd',
        name: 'medicineAdd',
        component: () => import('@/views/system/medicine/add'),
        meta: { title: '添加药品', icon: 'table' },
        hidden: true
      },
      {
        path: 'medicineEdit/:id',
        name: 'medicineEdit',
        component: () => import('@/views/system/medicine/add'),
        meta: { title: '编辑', icon: 'table' },
        hidden: true
      },

      //轮播图管理
      {
        path: 'carouselChartList',
        name: 'carouselChartList',
        component: () => import('@/views/system/carouselChart/index'),
        meta: { title: '轮播图管理表', icon: 'table' }
      },
      {
        path: 'carouselChartAdd',
        name: 'carouselChartAdd',
        component: () => import('@/views/system/carouselChart/add'),
        meta: { title: '添加轮播图', icon: 'table' },
        hidden: true
      },
      {
        path: 'carouselChartEdit/:id',
        name: 'carouselChartEdit',
        component: () => import('@/views/system/carouselChart/add'),
        meta: { title: '编辑轮播图', icon: 'table' },
        hidden: true
      },

      //标签管理
      {
        path: 'label',
        name: 'Label',
        component: () => import('@/views/system/label/label'),
        meta: { title: '标签管理', icon: 'form' }
      },
      {
        path: 'index',
        name: 'Form',
        component: () => import('@/views/form/index'),
        meta: { title: '设置', icon: 'form' }
      },

    ]
  },

  {
    path: '/nested',
    component: Layout,
    redirect: '/nested/menu1',
    name: 'Nested',
    meta: {
      title: 'Nested',
      icon: 'nested'
    },
    children: [
      {
        path: 'menu1',
        component: () => import('@/views/nested/menu1/index'), // Parent router-view
        name: 'Menu1',
        meta: { title: 'Menu1' },
        children: [
          {
            path: 'menu1-1',
            component: () => import('@/views/nested/menu1/menu1-1'),
            name: 'Menu1-1',
            meta: { title: 'Menu1-1' }
          },
          {
            path: 'menu1-2',
            component: () => import('@/views/nested/menu1/menu1-2'),
            name: 'Menu1-2',
            meta: { title: 'Menu1-2' },
            children: [
              {
                path: 'menu1-2-1',
                component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
                name: 'Menu1-2-1',
                meta: { title: 'Menu1-2-1' }
              },
              {
                path: 'menu1-2-2',
                component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
                name: 'Menu1-2-2',
                meta: { title: 'Menu1-2-2' }
              }
            ]
          },
          {
            path: 'menu1-3',
            component: () => import('@/views/nested/menu1/menu1-3'),
            name: 'Menu1-3',
            meta: { title: 'Menu1-3' }
          }
        ]
      },
      {
        path: 'menu2',
        component: () => import('@/views/nested/menu2/index'),
        meta: { title: 'menu2' }
      }
    ]
  },

  {
    path: 'external-link',
    component: Layout,
    children: [
      {
        path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
        meta: { title: 'External Link', icon: 'link' }
      }
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
